/**
 * 
 */
package com.nwpusp.controller;

import java.util.ArrayList;

import com.nwpusp.controller.actions.*;
import com.nwpusp.model.GameModel;
import com.nwpusp.model.StaticEntity;
import com.nwpusp.model.barrier.Barrier;
import com.nwpusp.model.characters.GameCharacter;
import com.nwpusp.model.location.Axis;
import com.nwpusp.model.location.Velocity;
import com.nwpusp.model.players.GameRecord;
import com.nwpusp.model.players.Player;
import com.nwpusp.model.players.Player.PlayerStatus;
import com.nwpusp.model.props.Prop;
import com.nwpusp.model.session.ConnectionId;

/**
 * @author JustinCao
 *
 */

public class Event2ActionTranslator {
	public static Action addPlayer(ConnectionId cid, String playerName, GameCharacter ch, GameRecord record, Player.PlayerStatus sts) {
		return new PlayerAddAction(playerName, cid, ch, record, sts);
	}
	public static Action removePlayer(ConnectionId cid) {
		return new PlayerRemoveAction(cid);
	}
	
	public static Action Tick(int tickCnt) {
		return new TickModelAction(tickCnt);
	}
	public static Action Collide(ConnectionId cid, StaticEntity ss) {
		if(ss instanceof Prop) {
			return new PropCollideAction(cid, ss);
		}
		if(ss instanceof Barrier) {
			return new BarrierCollideAction(cid, ss);
		}
		return null;
	}
	
	public static Action readyGame(ConnectionId cid) {
		GameProcessAction a = new GameProcessAction(GameProcessAction.ProcessType.ready);
		a.setConnectionId(cid);
		return a;
	}
	
	public static Action startGame() {
		return new GameProcessAction(GameProcessAction.ProcessType.start);
	}
	
	public static Action stopGame() {
		return new GameProcessAction(GameProcessAction.ProcessType.stop);
	}
	
	public static Action characterJump(ConnectionId cid) {
		return new CharacterAction(cid, CharacterAction.ActionType.jump, 0);
	}
	
	public static Action characterLaydown(ConnectionId cid) {
		return new CharacterAction(cid, CharacterAction.ActionType.laydown, 0);
	}
	
	public static Action cancelGame(ConnectionId cid) {
		return new CancelGameAction(cid);
	}
	public static Action trackDirectionMove(ConnectionId cid, int moveValue) {
		return new CharacterAction(cid, CharacterAction.ActionType.trackMove, moveValue);
	}
	public static Action trackShift(ConnectionId cid, int direction) {
		return new CharacterAction(cid, CharacterAction.ActionType.trackShift, direction);
	}
	public static Action enterGameReq(GameModel m, ConnectionId monitorCid, ArrayList<ConnectionId> cids, ArrayList<Axis> axes) {
		return new EnterGameReqAction(m, monitorCid, cids, axes);
	}
	public static Action Response(int syncId, ConnectionId rspCid) {
		return new SyncRspAction(syncId, rspCid);
	}
	public static Action initRawStaticEntities(ArrayList<Axis> axes) {
		return new InitRawStaticEntityAxes(axes);
	}
	public static Action reportPlayer(ConnectionId cid, Axis position, Velocity velocity) {
		return new PlayerReportAction(cid, position, velocity);
	}
}
